package features;

import java.io.File;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.vecmath.Color3f;
import operationSolids.CompoundSolid;
import operationSolids.OperationCylinder;
import CAD.MainFrame;
import bool.Solid;

public class FlatHoleBottom extends Feature{

	public float radius =0;
	float depth = 0;
	
	public FlatHoleBottom(int type, Feature Mae,float depth, float radius, float posx, float posy, float posz, String name,int face) {
		
		super(type, Mae, name);
		this.radius = radius;
		this.depth = depth;
		
		feature = new OperationCylinder(name, radius, depth);
		create(posx,posy,posz,face);
		MainFrame.features.add(this);
		MainFrame.refreshJTree();
				
	}

	void translate() {
		feature.translate(placement.getX(), placement.getY() - depth/2, placement.getZ());	
		switch (MainFrame.Face) 
		{
		case MainFrame.BACKFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.FRONTFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.EASTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.WESTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.LOWERFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;
		case MainFrame.TOPFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;

		default:
			System.out.println("erro");
			break;
		}
	}
	@Override
	void compound() {
		MainFrame.block  = new Block ("comp",CompoundSolid.DIFFERENCE,MainFrame.block, feature);
	}


	@Override
	public void drawNode(DefaultMutableTreeNode node) {
		node.add(
				new DefaultMutableTreeNode(
				"Radius:"+radius+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"Depth:"+depth+"mm")
				);
	}
	
	public float getRadius() {
		return radius;
	}

	
	public float getDepth() {
		return depth;
	}
	
}
